﻿using Consul;

namespace ServiceFind
{
    internal class Program
    {
        static void Main(string[] args)
        {
             using (ConsulClient consul=new ConsulClient(options => { options.Address = new Uri("http://127.0.0.1:8500");options.Datacenter = "dc1"; }))
            {

                //while (true)
                {
                    var services = consul.Agent.Services().Result;
                   
                    var dic = services.Response;
                    foreach (var item in dic)
                    {
                        Console.WriteLine($"key:{item.Key},service :{item.Value.Service}, port :{item.Value.Port}");
                        Console.WriteLine($" address {item.Value.Address}");
                    }
                    Thread.Sleep(2000);

                }
              
            }
        }
    }
}